//
//  SQLCommandHandle+creatTable.m
//  SQL面向对象数据库封装
//
//  Created by 崔博 on 2018/9/25.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "SQLCommandHandle+creatTable.h"

@implementation SQLCommandHandle (creatTable)

- (void)preSqlCreateTabelName:(NSString *)tableName column:(NSDictionary *)colounmInfo
{
//    @"create table if not exists eoctable(id char, name char)";
    self.sqlCommand = [NSMutableString string];
    NSString *tableSturt = nil;
    NSMutableArray * colomnArray = [NSMutableArray array];
    [colounmInfo enumerateKeysAndObjectsUsingBlock:^(NSString *  _Nonnull key, NSString*  _Nonnull obj, BOOL * _Nonnull stop) {
        if (key.length == 0 || obj.length == 0) {
            NSLog(@"创建表,表的字段有问题");
        }else
        {
            NSString *comstr = [NSString stringWithFormat:@"%@ %@",key,obj];
            [colomnArray addObject:comstr];
        }
        
    }];
    tableSturt = [colomnArray componentsJoinedByString:@","];
    [self.sqlCommand appendFormat:@"create table if not exists %@(%@)",tableName,tableSturt];
}
@end
